package com.example.datastorage;

import androidx.appcompat.app.AppCompatActivity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;

import java.util.HashSet;
import java.util.Set;

public class MsgActivity extends AppCompatActivity {

    private TextView txtMsg;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_msg);

        txtMsg = (TextView) findViewById(R.id.txtMsg);

        SharedPreferences userInfo = getSharedPreferences("userInfo", MODE_PRIVATE);
        String user = userInfo.getString("user", "");
        Set<String> password = userInfo.getStringSet("password", new HashSet<>());
        String age = userInfo.getString("age", "");
        String sex = userInfo.getString("sex", "");
        if (sex.equals("true")){
            sex = "男";
        }else if (sex.equals("false")){
            sex = "女";
        }else {
            sex = "格式错误";
        }
        txtMsg.setText("账户："+user+"\n密码："+password.toArray()[1]+"\n年龄："+age+"\n性别："+sex);
    }
}